<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGroupOrderBatchesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('group_order_batches', function (Blueprint $table) {
            $table->id();
            $table->date('group_date')->comment('拼团日期')->index('group_date');
            $table->dateTime('end_date')->comment('结算时间')->index('end_date');
            $table->unsignedBigInteger('user_id')->comment('用户id');
            $table->unsignedBigInteger('product_id')->comment('商品id');
            $table->tinyInteger('type')->comment('类型 1-奖金 2-分红积分');
            $table->tinyInteger('batch')->comment('批次')->default(1)->index('batch');
            $table->tinyInteger('status')->default(0)->comment('状态');
            $table->tinyInteger('for_sale')->default(0)->comment('1-挂卖 2-提货');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `group_order_batches` comment '拼单批次'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('group_order_batches');
    }
}
